package ctrFinanceiro.dmp;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;


/**
 * The persistent class for the cfin_conta database table.
 * 
 */
@Entity
@Table(name="cfin_conta", schema = "financeiro")
@NamedQueries({
	@NamedQuery(name = "Conta.findAll", 
			query = "SELECT u FROM Conta u WHERE u.usuario.idUsu = :p0 ORDER BY u.categoria.tipo, u.idCta"),
	@NamedQuery(name = "Conta.findByDescricao", 
			query = "SELECT u FROM Conta u WHERE u.usuario.idUsu = :p0 AND u.descricao = :p1"),
	@NamedQuery(name = "Conta.findBy1TipoCategoria", 
			query = "SELECT u FROM Conta u WHERE u.usuario.idUsu = :p0 AND u.categoria.tipo = :p1 "),
	@NamedQuery(name = "Conta.findBy2TipoCategoria", 
			query = "SELECT u FROM Conta u WHERE u.usuario.idUsu = :p0 AND u.categoria.tipo = :p1 OR u.categoria.tipo = :p2 ")
	})
public class Conta implements Serializable {
	private static final long serialVersionUID = 1L;

	@Id
	@SequenceGenerator(name="CFIN_CONTA_IDCTA_GENERATOR", sequenceName = "financeiro.cfin_conta_id_cta_seq" , allocationSize = 1  )
	@GeneratedValue(strategy=GenerationType.SEQUENCE, generator="CFIN_CONTA_IDCTA_GENERATOR")
	@Column(name="id_cta", unique=true, nullable=false)
	private Integer idCta;

	@Column(nullable=false, length=100)
	private String descricao;

	//bi-directional many-to-one association to CfinCategoria
    @ManyToOne
	@JoinColumn(name="id_cat", nullable=false)
	private Categoria categoria;

	//bi-directional many-to-one association to Usuario
    @ManyToOne
	@JoinColumn(name="id_usu", nullable=false)
	private Usuario usuario;

	//bi-directional many-to-one association to CfinMovimento
/*	@OneToMany(mappedBy="ctaDestino")
	private List<Movimento> destinos;
*/
	//bi-directional many-to-one association to CfinMovimento
/*	@OneToMany(mappedBy="ctaOrigem")
	private List<Movimento> origens;*/
    
    public Conta() {
    }

    public Conta(Integer idCta, String descricao, Categoria categoria, Usuario usuario) {
		super();
		if (null != idCta) {
			this.idCta = idCta;
		}
		this.descricao = descricao;
		this.categoria = categoria;
		this.usuario = usuario;
	}


	public Integer getIdCta() {
		return this.idCta;
	}

	public void setIdCta(Integer idCta) {
		this.idCta = idCta;
	}

	public String getDescricao() {
		return this.descricao;
	}

	public void setDescricao(String descricao) {
		this.descricao = descricao;
	}

	public Categoria getCategoria() {
		return categoria;
	}

	public void setCategoria(Categoria categoria) {
		this.categoria = categoria;
	}

	public Usuario getUsuario() {
		return this.usuario;
	}

	public void setUsuario(Usuario usuario) {
		this.usuario = usuario;
	}

	@Override
	public String toString() {
		return idCta + " - " + descricao;
	}
	
	
	
	/*	public List<Movimento> getCfinMovimentos1() {
		return this.cfinMovimentos1;
	}

	public void setCfinMovimentos1(List<Movimento> cfinMovimentos1) {
		this.cfinMovimentos1 = cfinMovimentos1;
	}
	
	public List<Movimento> getCfinMovimentos2() {
		return this.cfinMovimentos2;
	}

	public void setCfinMovimentos2(List<Movimento> cfinMovimentos2) {
		this.cfinMovimentos2 = cfinMovimentos2;
	}
*/	
}